package com.micro.modual.model.bo.coupontemplate;

import com.micro.modual.model.enums.CouponCategory;
import com.micro.modual.model.enums.DistributeTarget;
import com.micro.modual.model.enums.ProductLine;
import com.micro.modual.model.vo.TemplateRule;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * <h1>优惠券模版表表 新增/修改 请求对象</h1>
 *
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@ApiModel(description = "优惠券模版表新增/修改 请求对象")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CouponTemplateBO {

    private Long id;

    /**
     * 优惠券名称
     */
    private String name;

    /**
     * 优惠券logo
     */
    private String logo;

    /**
     * 优惠券描述
     */
    private String desc;

    /**
     * 优惠券分类
     */
    private String category;

    /**
     * 产品线
     */
    private Integer productLine;

    /**
     * 优惠券数量
     */
    private Integer count;


    /**
     * 目标用户
     */
    private Integer target;

    /**
     * 优惠券规则
     */
    private TemplateRule rule;

    /**
     * 基础校验:校验对象的合法性
     * @return
     */
    public boolean validata(){
        boolean stringValid = StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(logo) && StringUtils.isNotEmpty(desc);
        boolean enumValid = null != CouponCategory.of(category) &&  null != ProductLine.of(productLine) && null != DistributeTarget.of(target);
        boolean numValid = count > 0 ;
        return stringValid && enumValid && numValid && rule.validata();
    }
}
